/*
* Copyright (c) 2011 Connection Road.  All rights reserved.
* This program and the accompanying material are made available
* under the terms of the Eclipse Public Licnese v1.0 which is
* available at http://www.eclipse.org/legal/epl-v10.html
*/

using System.IO;

namespace CrSyncFilesUtils {
    
    
    /// <summary>
    /// Utility class for various directory validation.
    /// </summary>
    /// 
    public class DirectoryValidator {



        /// <summary>
        /// Class constructor
        /// </summary>
        /// <param name="aPath">An absolute path</param>
        public DirectoryValidator(string aPath) {
            DirectoryPath = aPath;
        }




        public string DirectoryPath {
            get;
            set;
        }


        /// <summary>
        /// Checks if the given file papth is a valid directory and it exists.
        /// </summary>
        /// <returns>0 for successfull</returns>
        /// <returns>-1 if the specified path does not exists</returns>
        /// <returns>-2 if </returns>
        public DirectoryValidatorResult Validate() {
            var currentPath = DirectoryPath.ToUpper();
            if ((currentPath.Contains(":\\")) || (currentPath.StartsWith("\\")))
            {
                return Directory.Exists(currentPath) ? DirectoryValidatorResult.Exists : DirectoryValidatorResult.DoesNotExists;
            }
            return DirectoryValidatorResult.InvalidPath;
        }
    }
}
